<?php
namespace app\single\controller;
class Customer extends Common{
    /**
     * 客户端推送信息
     * @param  string  $message 信息内容
     * @param  integer $relation_id 回复会员ID
     * @return json
     */
    function push($message='',$relation_id=0){
        if(empty($message)){
            return json('信息不能为空',1);
        }
        $add=model($this->table)->push($this->user['id'],$message,$relation_id);
        if(!empty($add)){
            $data=null;
            if($relation_id==0){
                $data=model('article')->readAll([
                    'cate_id'=>1,
                    'title'=>['title','like',"%{$message}%"],
                ],5,['field'=>'id,title'])->toArray();
                $data=$data['data'];
                $domain=request()->domain();
                foreach ($data as $k => $v) {
                    $data[$k]['text']=url('index/single/helpdetail',['id'=>$v['id']],'html',$domain);
                }
            }
            return json('',0,$data);
        }
        return json('发送信息失败',1);
    }
    /**
     * 客户端拉取信息记录
     * @param  integer $s_time 起始时间戳
     * @param  integer $e_time 结束时间戳
     * @return json
     */
    function pull($s_time=0,$e_time=0){
        $list=model($this->table)->pull($this->user['id'],$s_time,$e_time); 
        return json('',0,$list);
    }

    
}